<%-- 
    Document   : allCustomers
    Created on : 24.11.2012, 17:45:44
    Author     : Jan Novotný
--%>
<%@page contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@taglib prefix="s" uri="http://stripes.sourceforge.net/stripes.tld" %>
<%@taglib prefix="f" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 
<s:layout-render name="/layout_admin.jsp">
    <s:layout-component name="content">
        <s:useActionBean beanclass="cz.muni.fi.pa165.travelagency.web.CustomerActionBean" var="actionBean"/>
        
        <s:link beanclass="cz.muni.fi.pa165.travelagency.web.CustomerActionBean" event="new-customer"><f:message key="customer.create" /></s:link>
        <br>
        <br>
        
        <c:if test="${not empty actionBean.allCustomers}">
            <s:form beanclass="cz.muni.fi.pa165.travelagency.web.CustomerActionBean">
                <s:text id="find" name="find"/>
                <s:submit name="find"><f:message key="customer.find"/></s:submit>
            </s:form>
        </c:if>
        
        <c:choose>
            <c:when test="${not empty actionBean.customers}">
                <h3><f:message key="customer.all"/></h3>


                <table class="customers">
                    <tr>
                        <th><f:message key="customer.id"/></th>
                        <th><f:message key="customer.name"/></th>
                        <th><f:message key="customer.address"/></th>
                        <th><f:message key="customer.phone-number"/></th>
                        <th></th>
                        <th></th>
                        <th></th>
                    </tr>
                    <c:forEach items="${actionBean.customers}" var="c">
                        <tr>
                            <td><c:out value="${c.id}"/></td>
                            <td><c:out value="${c.name}"/></td>
                            <td><c:out value="${c.address}"/></td>
                            <td><c:out value="${c.phoneNumber}"/></td>
                            <td><s:link beanclass="cz.muni.fi.pa165.travelagency.web.OrderActionBean" event="orders-of-customer"><s:param name="customer.id" value="${c.id}"/><f:message key="order.orders" /></s:link></td>
                            <td><s:link beanclass="cz.muni.fi.pa165.travelagency.web.CustomerActionBean" event="delete"><s:param name="customer.id" value="${c.id}"/><f:message key="action.delete" /></s:link></td>
                            <td><s:link beanclass="cz.muni.fi.pa165.travelagency.web.CustomerActionBean" event="edit-customer"><s:param name="customer.id" value="${c.id}"/><f:message key="action.edit" /></s:link></td>
                        </tr>
                    </c:forEach>
                </table>
            </c:when>
            <c:otherwise>
                <f:message key="customer.none-found"/>
            </c:otherwise>
        </c:choose>
    </s:layout-component>
</s:layout-render>
